<?php

namespace api\libs\notifications\models;

use api\components\helpers\Constant;
use api\modules\app\models\DictContext;
use Yii;

/**
 * This is the model class for table "notification_record".
 *
 * @property integer $id
 * @property integer $template_id
 * @property integer $type
 * @property integer $business_type
 * @property integer $recipient
 * @property integer $is_read
 * @property integer $status
 * @property string $content
 * @property string $ctime
 * @property integer $cuser
 * @property string $mtime
 * @property integer $muser
 */
class NotificationRecord extends \yii\db\ActiveRecord {
    
    
    /**
     * inbox notification
     */
    const TYPE_INBOX = 1;

    /**
     * system notification
     */
    const TYPE_SYSTEM_NOTIE = 4;

    /**
     * upgrade notification
     */
    const TYPE_UPGRADE_NOTICE = 5;
    
    
    const BUSINESS_TYPE_SYSTEM = 1;
    
    const BUSINESS_TYPE_AUDIT = 2;
    
    const BUSINESS_TYPE_FINANCE = 3;
    
    const BUSINESS_TYPE_ACCOUNT = 4;

    /**
     * @inheritdoc
     */
    public static function tableName() {
        return 'notification_record';
    }

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
                [['template_id', 'type', 'recipient', 'is_read', 'status', 'cuser', 'muser', 'campaign_id'], 'integer'],
                [['recipient', 'is_read', 'status', 'content'], 'required'],
                [['content'], 'string'],
                [['ctime', 'mtime'], 'safe'],
                ['status', 'in', 'range' => DictContext::getListByType(Constant::DICT_CONTEXT_TYPE_COMMON_STATUS)],
                ['is_read', 'in', 'range' => DictContext::getListByType(Constant::DICT_CONTEXT_TYPE_COMMON_TYPE)],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'template_id' => 'Template ID',
            'type' => 'Type',
            'recipient' => '收件人',
            'is_read' => '0-NOT READ 1-IS_READ',
            'status' => '0-有效 1-删除',
            'content' => 'Content',
            'ctime' => 'Ctime',
            'cuser' => 'Cuser',
            'mtime' => 'Mtime',
            'muser' => 'Muser',
            'campaign_id' => 'Campaign ID',
        ];
    }

}
